package com.example.myapplication.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import androidx.appcompat.app.AppCompatActivity;
import com.example.myapplication.R;

/**
 * @author ayatsuji
 * @date 2021-09-23 22:53
 * @since
 */
public class CollectionActivity extends AppCompatActivity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_collection);

        TextView textView = findViewById(R.id.collectionFirst);
        textView.setText(getIntent().getStringExtra("title"));

        // 点击按钮后返回处理结果
        Button button = findViewById(R.id.yaiya);
        button.setOnClickListener(view -> {
            Intent intent = new Intent();
            intent.putExtra("result", "这是处理结果");
            setResult(RESULT_OK, intent);
            finish();
        });
    }

    // 点回退时返回结果
    @Override
    public void onBackPressed() {
        Intent intent = new Intent();
        intent.putExtra("result", "这是处理结果");
        setResult(RESULT_OK, intent);
        finish();
//        super.onBackPressed();
    }
}
